/* File: pi.as Project: did_u_hear_a_color 3___1_4____1_5____ Release: www.microsound.org/pi Products: did_u_hear_a_color.gif nisi_didUHearAColor_128k.mp3 Author: Michael Nisi Date: 2003-03-09 Class: Block() Methods: setPosition (x, y) setSize (w, h) fastRGB (r, g, b) Functions: loadExternals () handleLoad () createBlock (x, y, w, h, num) buildScore() ------------------------------------------------------------------ */ Block = function () { this.setPosition (this.params.x, this.params.y); this.setSize(this.params.w, this.params.h); this.fastRGB(this.params.r, this.params.g, this.params.b); delete this.params; } Block.prototype = new MovieClip(); Object.registerClass("blockSymbol", Block); Block.prototype.setPosition = function (x, y) { this._x = x; this._y = y; } Block.prototype.setSize = function (w, h) { this._width = w; this._height = h; } Block.prototype.fastRGB = function(r, g, b) { if (!isNaN(r) && !isNaN(g) && !isNaN(b) && r<256 && r>=0 && g<256 && g>=0 && b<256 && b>=0) { r = r<<16; g = g<<8; b = b; rgb = r|g|b; col = new Color(this); col.setRGB(rgb); } } function loadExternals (path) { data = new LoadVars(); data.load(path); data.onLoad = handleLoad; } function handleLoad (success) { temp_array = new Array(); blocks = new Array(); var i = 0; var z = 0; var l = data.piTt.length; while (i <= 10000) { temp_array[i] = data.piTt.charAt(i); i++; } while (n <= 2000) { blocks[z] = temp_array.slice(n, n+5); n+=5; z++; } buildScore(); } function createBlock (x, y, w, h, r, g, b, num) { var cellParams = new Object(); cellParams.x = x; cellParams.y = y; cellParams.w = w; cellParams.h = h; cellParams.r = r; cellParams.g = g; cellParams.b = b; var initObj = new Object(); initObj.params = cellParams; var id = "block"+num; this.attachMovie("blockSymbol", id, num, initObj); } function buildScore () { var i = 0; while (i <= 2000) { var x = i*Math.PI*2; var y = blocks[i][0]*Math.pow(Math.PI, 2); var w = blocks[i][1]*Math.pow(Math.PI, 2); var h = blocks[i][2]; var r = 255/blocks[i][3]; var g = 255/blocks[i][4]; var b = 0; createBlock(x, y, w, h, r, g, b, i); i++; } } loadExternals("pi10000.txt");